package com.tjtt.tdm.system.dao.impl;
import java.util.Map;

import com.tjtt.tdm.base.HibernateEntityDAO;
import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.system.bean.LogInfo;
import com.tjtt.tdm.system.bean.SysTips;
import com.tjtt.tdm.system.dao.ITipsDao;

public class TipsDaoImpl extends HibernateEntityDAO<LogInfo> implements ITipsDao {
    //查询所有日志信息
	public PageResult queryTips(Map filterMap) {
		StringBuffer queryString = new StringBuffer();
		queryString.append("from SysTips where 1=1 ");
		if (filterMap!= null && !filterMap.isEmpty()) {
			if(null != filterMap.get("logUserName") &&! "".equals(filterMap.get("logUserName"))){
				queryString.append("and LOG_USER_NAME like '%" + filterMap.get("logUserName") + "%' ");
			}
			String sidx = (String) filterMap.get("sidx");
			String sord = (String) filterMap.get("sord");
			queryString.append("order by " + sidx + " " + sord + " ");
		}
		return searchPaginated(queryString.toString(), filterMap);
	}
 
	@Override
	public void saveTip(SysTips tip) {
		this.getHibernateTemplate().save(tip);
	}

	@Override
	public void updateTip(SysTips tip) {
		this.getHibernateTemplate().update(tip);
	}

	@Override
	public void deleteTip(String ids) {
		String[] idss = ids.split(",");
		for(String id : idss){
			SysTips tip = this.getHibernateTemplate().get(SysTips.class, Long.parseLong(id));
			this.getHibernateTemplate().delete(tip);
		}
	}

	@Override
	public SysTips getOneTip(String id) {
		SysTips tip = this.getHibernateTemplate().get(SysTips.class, Long.parseLong(id));
		return tip;
	}
   
}
